import axios from 'axios';

const instance=axios.create({
    baseURL: process.env.VUE_APP_SERVER_URL,
    timeout: 6000
})

 instance.interceptors.request.use(
    config => {
      console.log(config);
        if (localStorage.token) {  // 判断是否存在token，如果存在的话，则每个http header都加上token
            config.headers.Authorization ='Bearer '+ localStorage.token;
        }
        return config;
    },
    err => {
        return Promise.reject(err);
  });

export default instance;